﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using UTSDAL.LINQSQL.Model;

namespace UTSDAL.LINQSQL.DAO
{
    public class ModuleDAO:GenericDAO<Module,Guid>
    {

        private CohortDAO cohortDAO = new CohortDAO();

        public List<Module> findModulesByCohortId(Guid cohortId)
        {
            Cohort cohort = cohortDAO.findById(cohortId);

            return findModulesByCohort(cohort);

        }

        public List<Module> findModulesByCohort(Cohort cohort)
        {
                       
            
            var modulesVar = from m in base.Context.CohortModules
                             where m.Cohort.Equals(cohort)
                             select m.Module;

            return modulesVar.ToList<Module>();
        }


        public List<Module> findModulesByCohortAndSemester(Cohort cohort,Semester semester)
        {


            var modulesVar = from m in base.Context.CohortModules
                             where m.Cohort.Equals(cohort)
                             && m.Semester.Equals(semester)
                             select m.Module;

            return modulesVar.ToList<Module>();
        }

    }
}
